home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / hello_localized / hello3.asm < prev    next >
Assembly Source File  |  1995-09-01  |  2KB  |  113 lines

  1.  
  2. AbsExecBase        equ    4
  3. _LVOOldOpenLibrary    equ    -408
  4. _LVOOpenLibrary        equ    -552
  5. _LVOCloseLibrary    equ    -414
  6. _LVOOutput        equ    -$3C
  7. _LVOWrite        equ    -$30
  8. MSG_HELLO        equ    0
  9. LF            equ    10
  10.  
  11. CALL        macro
  12.         jsr    _LVO\1(a6)
  13.         endm
  14.  
  15.         section    main,code
  16.  
  17. *-------------- Startup...
  18.  
  19. Begin:        lea    _Catalog(pc),a4            ;DT Area...
  20.  
  21.         move.l    (AbsExecBase).w,a6
  22.         lea    DOSName(pc),a1
  23.         CALL    OldOpenLibrary            ;open dos (any ver)
  24.         move.l    d0,_DOSBase-DT(a4)
  25.  
  26.         move.l    d0,a6
  27.         CALL    Output                ;get output
  28.         move.l    d0,_Output-DT(a4)
  29.  
  30.         lea    LocaleName(pc),a1
  31.         moveq    #38,d0                ;version 38+
  32.         move.l    (AbsExecBase).w,a6
  33.         CALL    OpenLibrary            ;open locale
  34.         move.l    d0,_Locale-DT(a4)
  35.         beq.s    no_local
  36.  
  37.         lea    CatalogName(pc),a1        ;name of catalog
  38.         suba.l    a0,a0                ;no tags or lang
  39.         suba.l    a2,a2
  40.         move.l    d0,a6
  41.         jsr    -$96(a6)            ;open catalog
  42.         move.l    d0,_Catalog-DT(a4)
  43.  
  44. no_local:
  45.  
  46. *-------------- Example call...
  47.  
  48.         lea    HelloWorld.txt(pc),a0        ;default string
  49.         moveq    #MSG_HELLO,d0            ;string.no in catalog
  50.         bsr.s    _PutStr
  51.  
  52. *-------------- Shutdown...
  53.  
  54.         move.l    (a4),d0                ;_Catalog-DT(a4),d0
  55.         beq.s    CloseLocale
  56.         move.l    d0,a0
  57.         move.l    _Locale-DT(a4),a6
  58.         jsr    -$24(a6)            ;close catalog
  59.  
  60. CloseLocale:    move.l    _Locale-DT(a4),d0
  61.         beq.s    CloseDos
  62.         move.l    d0,a1
  63.         move.l    (AbsExecBase).w,a6
  64.         CALL    CloseLibrary            ;close locale
  65.  
  66. CloseDos:    move.l    _DOSBase-DT(a4),d0
  67.         beq.s    ExitCLI
  68.         move.l    d0,a1
  69.         move.l    (AbsExecBase).w,a6
  70.         CALL    CloseLibrary            ;close dos
  71.  
  72. ExitCLI:    moveq    #0,d0                ;return 0 for cli..
  73.         rts
  74.  
  75. ******************************************************************************
  76. * PutStr
  77. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  78. ******************************************************************************
  79.  
  80. _PutStr:    move.l    d0,d7
  81.         move.l    a0,a1
  82.         move.l    (a4),a0            ;_Catalog-DT(a4),a0
  83.         move.l    d7,d0
  84.         move.l    _Locale-DT(a4),a6
  85.         jsr    -$48(a6)        ;GetLocaleStr
  86.  
  87.         move.l    d0,d6
  88.         move.l    d0,a0
  89. .strlen:    tst.b    (a0)+            ;get string length
  90.         bne.s    .strlen
  91.         subq.l    #1,a0
  92.         sub.l    d0,a0
  93.         move.l    a0,d3
  94.  
  95.         move.l    _Output-DT(a4),d1
  96.         move.l    d6,d2
  97.         move.l    _DOSBase-DT(a4),a6
  98.         jsr    _LVOWrite(a6)        ;write to cli..
  99.         rts
  100. DT:
  101. _Catalog:    ds.l    1
  102. _Locale:    ds.l    1
  103. _DOSBase:    ds.l    1
  104. _Output:    ds.l    1
  105. DOSName:    dc.b    'dos.library',0
  106.         even
  107. LocaleName:    dc.b    'locale.library',0
  108.         even
  109. CatalogName:    dc.b    'hello.catalog',0
  110.         even
  111. HelloWorld.txt:    dc.b    'Hello World!',LF,0
  112.         even
  113.